#ifndef COMPACTNET_H_
#define COMPACTNET_H_

#include <vector>
#include <auto_ptr.h>

#include "graph_support/IGraph.h"

#include "graph_support/alg_correctness_tests/generate_graph/FlowEdgeAttributes4UnitTests.h"


namespace dinic_alg_test
// TODO: move 2 proper place: not only Dinic -- same in other classes / files
{

class CompactNet
{
public:
	int * st;
	int * nx;
	int * a;
	double * cap;
	double * flow;
	double * cost;

public:
	CompactNet( int vertCount, int edgCount, bool hasCost = false );

public:
	int getVertCount();
	int getEdgCount();
	void addEdge( int a, int b, double capacity );
	void addEdge( int a, int b, double capacity, double cost );
	double remainFlow( int edge );
	void clear();

private:
	static double NaN;
	void addSingleEdge( int a, int b, double capacity, double cost );

private:
	std::vector< int > stBuf;
	std::vector< int > nxBuf;
	std::vector< int > aBuf;
	std::vector< double > capBuf;
	std::vector< double > flowBuf;
	std::vector< double > costBuf;
	int k;
};
typedef std::auto_ptr< CompactNet > CompactNetPtr;

void cpgr2compact( GRAPH_SUPPORT_NS::IGraph & gr, CompactNet & d, double eps = 1e-5 );
CompactNetPtr clonegr2compact( GRAPH_SUPPORT_NS::IGraph & gr, bool hasCost = false );

}

#endif /* COMPACTNET_H_ */
